package evo.springboot.controller;

import evo.springboot.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping(value = "/user")
public class UserController {
    @RequestMapping(value = "/login")
    public @ResponseBody Object login(HttpServletRequest request){
        User user = new User();
        user.setId(1);
        user.setName("jojo");
        request.getSession().setAttribute("user",user);
        return "login SUCCESS";
    }

    @RequestMapping(value = "/center")
    public @ResponseBody Object center(){
        return "See Center";
    }

    //不登录也可访问
    @RequestMapping(value = "/out")
    public @ResponseBody Object out(){
        return "Out See";
    }

    @RequestMapping(value = "/error")
    public @ResponseBody Object error(){
        return "error";
    }
}
